import Axios from 'axios';
import store from '../store.js';
export default {
    //获取门店信息
    store(){
        return new Promise((success,error)=>{
            Axios.post(sysinfo.url,Qs.stringify({
                pages:'store',
                doing:'store',
                uid:sysinfo.uid
            }))
                .then((res)=>{
                    if(res.data.status == 'success'){
                        store.set('store',res.data.data);
                        success(res.data.data);
                    }else{
                        success(0);
                    }
                })
                .catch(error=>console.log(error));
        });
    },
    //通过时间返回日期格式2019-10-20
    timeFormat(time){
        var month = time.getMonth()+1;
        if(month < 10) month = '0'+ month;
        var date = time.getDate();
        if(date < 10) date = '0'+date;
        return time.getFullYear()+'-'+month+'-'+date;
    },
    //获取近N天的时间
    getNearDate(day){
        var date = new Date(new Date().toLocaleDateString());
        var target_timestamp = date.getTime() + 86400000 * day;
        date.setTime(target_timestamp);
        return date;
    }
}
